# 打开日志文件
with open('2024-10-21_135813.log', 'r', encoding='utf-8') as f:
    lines = f.readlines()

# 处理日志行
output_lines = []
for line in lines:
    if "结束" in line:
        # 如果找到结束字眼，且是最后一行，则删除换行符
        output_lines[-1] = output_lines[-1].rstrip() + line.lstrip()  # 合并前一行和当前行
    else:
        output_lines.append(line)

# 写入新的日志文件
with open('2024-10-21_135813.log', 'w', encoding='utf-8') as f:
    f.writelines(output_lines)
